#!/usr/bin/env python
# -*- coding:utf-8 -*-
#

import socket
import threading
import socketserver
import json
import time

HOST, PORT = "localhost", 20001

# sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# sock.connect((HOST, PORT))


def client(sock, message):
    try:
        # print("Send: {}".format(message))
        sock.sendall(message.encode("utf-8"))
        # response = sock.recv(1024)
        # jresp = json.loads(response.decode('utf-8'))
        # print("Recv: ", jresp)

    finally:
        pass
        # sock.close()


if __name__ == "__main__":
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((HOST, PORT))
    msg = [{
        "request": 1
    }]

    jmsg = json.dumps(msg)
    for i in range(10000):
        msg = [{
            "request": 1
        }]
        print(i)
        jmsg = json.dumps(msg)
        sock.sendall(jmsg.encode("utf-8"))
    # time.sleep(1)
    # for i in range(10000):
    # client(sock,jmsg)
    print("done!")
